<%--
  Created by IntelliJ IDEA.
  User: lsj
  Date: 2025/10/31
  Time: 02:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page pageEncoding="UTF-8" %>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>员工管理 - 添加员工</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .form-container {
            background: white;
            padding: 40px;
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            width: 100%;
            max-width: 600px;
        }

        .form-header {
            text-align: center;
            margin-bottom: 30px;
        }

        .form-header h1 {
            color: #333;
            font-size: 28px;
            font-weight: 600;
            margin-bottom: 10px;
        }

        .form-header p {
            color: #6b7280;
            font-size: 16px;
        }

        .form-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
            margin-bottom: 30px;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-group.full-width {
            grid-column: 1 / -1;
        }

        .form-label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: #374151;
        }

        .form-label.required::after {
            content: " *";
            color: #ef4444;
        }

        .form-control {
            width: 100%;
            padding: 12px 16px;
            border: 2px solid #e5e7eb;
            border-radius: 10px;
            font-size: 14px;
            transition: all 0.3s ease;
        }

        .form-control:focus {
            outline: none;
            border-color: #4f46e5;
            box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
        }

        .form-actions {
            display: flex;
            gap: 15px;
            justify-content: flex-end;
            border-top: 1px solid #e5e7eb;
            padding-top: 30px;
        }

        .btn {
            padding: 12px 30px;
            border: none;
            border-radius: 10px;
            text-decoration: none;
            font-weight: 500;
            transition: all 0.3s ease;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 8px;
        }

        .btn-primary {
            background: #4f46e5;
            color: white;
        }

        .btn-primary:hover {
            background: #4338ca;
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(79, 70, 229, 0.3);
        }

        .btn-secondary {
            background: #6b7280;
            color: white;
        }

        .btn-secondary:hover {
            background: #4b5563;
            transform: translateY(-2px);
        }

        .error-message {
            background: #fef2f2;
            border: 1px solid #fecaca;
            color: #dc2626;
            padding: 12px 16px;
            border-radius: 10px;
            margin-bottom: 20px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        @media (max-width: 768px) {
            .form-grid {
                grid-template-columns: 1fr;
            }

            .form-container {
                padding: 25px;
                margin: 20px;
            }
        }
    </style>
</head>
<body>
<div class="form-container">
    <div class="form-header">
        <h1>👤 添加新员工</h1>
        <p>请填写员工的基本信息</p>
    </div>

    <c:if test="${not empty error}">
        <div class="error-message">
            <span>⚠️</span> ${error}
        </div>
    </c:if>

    <form action="employees" method="post">
        <input type="hidden" name="action" value="add">

        <div class="form-grid">
            <div class="form-group">
                <label class="form-label required">姓名</label>
                <input type="text" name="name" class="form-control" required
                       placeholder="输入员工姓名">
            </div>

            <div class="form-group">
                <label class="form-label required">部门</label>
                <input type="text" name="department" class="form-control" required
                       placeholder="输入部门">
            </div>

            <div class="form-group">
                <label class="form-label required">职位</label>
                <input type="text" name="position" class="form-control" required
                       placeholder="输入职位">
            </div>

            <div class="form-group">
                <label class="form-label required">薪资</label>
                <input type="number" name="salary" class="form-control" required
                       step="0.01" placeholder="输入薪资">
            </div>

            <div class="form-group">
                <label class="form-label">邮箱</label>
                <input type="email" name="email" class="form-control"
                       placeholder="输入邮箱地址">
            </div>

            <div class="form-group">
                <label class="form-label">电话</label>
                <input type="tel" name="phone" class="form-control"
                       placeholder="输入电话号码">
            </div>

            <div class="form-group full-width">
                <label class="form-label required">入职日期</label>
                <input type="date" name="hireDate" class="form-control" required>
            </div>
        </div>

        <div class="form-actions">
            <a href="employees" class="btn btn-secondary">
                <span>←</span> 返回列表
            </a>
            <button type="submit" class="btn btn-primary">
                <span>💾</span> 保存员工
            </button>
        </div>
    </form>
</div>

<script>
    // 设置默认日期为今天
    document.addEventListener('DOMContentLoaded', function() {
        const today = new Date().toISOString().split('T')[0];
        document.querySelector('input[name="hireDate"]').value = today;
    });
</script>
</body>
</html>